package org.tysite.tyservice.example.jsonview.controller;

import com.fasterxml.jackson.annotation.JsonView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tysite.tyservice.example.jsonview.dto.JsonViewInfoDTO;
import org.tysite.tyservice.example.jsonview.service.JsonViewService;

/**
 * JsonView对象属性过滤演示API入口
 * @author tysite
 * @date 2020/4/1 0001
 */
@RestController
@RequestMapping("/api/example/json-view")
public class JsonViewController {
    
    @Autowired
    private JsonViewService jsonViewService;

    @GetMapping("/list")
    @JsonView(JsonViewInfoDTO.ListView.class)
    public JsonViewInfoDTO demoList() {
        return jsonViewService.getJsonViewInfo();
    }
    
    @GetMapping("/detail")
    @JsonView(JsonViewInfoDTO.DetailView.class)
    public JsonViewInfoDTO demoDetail() {
        return jsonViewService.getJsonViewInfo();
    }
    
}
